package com.wcs.exam.controller.admin;

import com.wcs.exam.common.base.Result;
import com.wcs.exam.common.base.annotation.OptLog;
import com.wcs.exam.common.base.page.Page;
import com.wcs.exam.controller.admin.biz.AdminOrderInfoBiz;
import com.wcs.exam.controller.admin.req.AdminOrderInfoChangePriceReq;
import com.wcs.exam.controller.admin.req.AdminOrderInfoEditReq;
import com.wcs.exam.controller.admin.req.AdminOrderInfoPageReq;
import com.wcs.exam.controller.admin.resp.AdminOrderInfoPageResp;
import com.wcs.exam.controller.admin.resp.AdminOrderInfoViewResp;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

/**
 * Admin-订单信息
 *
 * @author wcs
 * @since 2025-03-17
 */
@Tag(name = "Admin-订单信息")
@RestController
@RequiredArgsConstructor
@RequestMapping("/v1/admin/order/info")
public class AdminOrderInfoController {

    @NotNull
    private final AdminOrderInfoBiz biz;

    @Operation(summary = "订单信息-分页")
    @OptLog(value = "订单信息-分页")
    @GetMapping(value = "/page")
    public Result<Page<AdminOrderInfoPageResp>> page(@ModelAttribute AdminOrderInfoPageReq req) {
        return biz.page(req);
    }

    @Operation(summary = "订单信息-查看")
    @OptLog(value = "订单信息-查看")
    @Parameter(name = "id", description = "主键ID", required = true)
    @GetMapping(value = "/view")
    public Result<AdminOrderInfoViewResp> view(@RequestParam Long id) {
        return biz.view(id);
    }

    @Operation(summary = "订单信息-编辑")
    @OptLog(value = "订单信息-编辑")
    @PutMapping(value = "/edit")
    public Result<String> edit(@RequestBody @Valid AdminOrderInfoEditReq req) {
        return biz.edit(req);
    }

    @Operation(summary = "订单信息-修改价格")
    @OptLog(value = "订单信息-修改价格")
    @PutMapping(value = "/change/price")
    public Result<String> changePrice(@RequestBody @Valid AdminOrderInfoChangePriceReq req) {
        return biz.changePrice(req);
    }

    @Operation(summary = "订单信息-删除")
    @Parameter(name = "id", description = "主键ID", required = true)
    @OptLog(value = "订单信息-删除")
    @DeleteMapping(value = "/delete")
    public Result<String> delete(@RequestParam Long id) {
        return biz.delete(id);
    }
}
